package 练习2;

//评委打分

import java.util.Scanner;

public class test10 {
    public static void main(String[] args) {
        int [] arr = new int[6];
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < arr.length; i++) {
            System.out.println("请输入第"+(i+1)+"个评委的打分:");
            arr[i] = sc.nextInt();
        }
        print(arr);
        int max  = getmax(arr);
        int min = getmin(arr);
        int sum = getsum(arr);

        int avg = (sum-max-min)/(arr.length-2);
        System.out.println("平均成绩为："+avg);


    }

    public static  int getsum (int[]arr){
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum+=arr[i];
        }
        return sum;
    }

    public static int getmin(int[] arr){
        int min = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if(min>arr[i]){
                min = arr[i];
            }
        }
        return min;
    }

    public static int getmax(int[] arr){
        int max = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if(max<arr[i]){
                max = arr[i];
            }
        }
        return max;
    }

    public static void print(int[] arr){
        System.out.print("[");
        for (int i = 0; i < arr.length; i++) {
            if(i==arr.length-1){
                System.out.print(arr[i]);
            }else{
                System.out.print(arr[i]+",");
            }
        }
        System.out.println("]");
    }

}
